<template>
	<view class="">
		<view class="">
			<view class="top u-flex u-row-between mode" v-for="(item,index) in list" :key="index" @click="select(item)">
				<view class="u-flex">
					<u-image src="/static/icon_address.png" width="60" height="60"></u-image>
					<view class="u-margin-left-20" style="width: 500rpx;">
						<view>
							<text style="font-size: 32rx;font-weight: bold;">{{item.realname}}</text>
							<text style="color:#999999;margin-left: 20rpx;margin-right: 20rpx;">{{item.phone}}</text>
							<u-tag text="默认" type="primary" size="mini" v-if="item.default_addr"/>
						</view>
						<view class="">
							{{item.address}}
						</view>
					</view>
				</view>
				<u-icon name="edit-pen" color="#628DFF" size="40" @click.stop="edit(item)"></u-icon>
			</view>


		</view>
 
    <view class="bottomFix">
		<u-button @click="submit" type="primary" :custom-style="{width:'500rpx'}" shape="circle">新增地址</u-button>
	</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []


			};
		},
		onShow() {
			this.getAddress()
		},
		methods: {
			select(item){
				let pages = getCurrentPages();             //获取所有页面栈实例列表
				let prevPage = pages[ pages.length - 2 ];  //上一页页面实例
				console.log(prevPage.route)
				if(prevPage.route=="pages/sure_book/index"){
					
					prevPage.$vm.address_id = item.id;         //修改上一页面的 couponNumber 参数值为 value
					uni.navigateBack({
							delta:1
					})	
				}
			
			},
			getAddress() {
				this.$u.post('/api//user/address', {
					
				}, {}).then(res => {
				  	this.list=res.data
				}).catch(err => {})
			
			},
			submit() {
				uni.navigateTo({
					url: "./addAddress"
				})
			},
			edit(item){
			   uni.navigateTo({
			   	url:"./addAddress?id="+item.id
			   })
			}
		},

	};
</script>



<style>
	@import "../../pages/my/common.css";

	.mode {
		padding: 20rpx !important;
	}

	.top {

		display: flex;
		justify-content: space-between;
		margin-top: 20rpx;
	}
</style>
